<template>
<div>
<h1>评论</h1>
<p>写：<input type="text" v-model="comment"></p>
  <button @click="add">提交</button></div>
</template>

<script>
export default {
  name: "news_com",
  data(){
  return{
  comment:'',
  userid:localStorage.getItem('userid'),
  id:this.$route.query.id

  }
  },
  methods:{
  add(){
  this.$axios.post('/news/com',{'comment':this.comment,'userid':this.userid,'id':this.id})
  .then(res=>{
  if (res.data.code==200){
  alert('ok')
  this.comment = ''
  }
  else {
  alert('评论失败')
  }
  })

  }
  }
}
</script>

<style scoped>

</style>
